import { Injectable } from '@nestjs/common';
import { formatSuccess, gateRestClient } from 'src/util';

@Injectable()
export class GateService {
  // 合约详情 getFuturesContract
  async contract(e: any) {
    const params: any = {
      ...e,
      settle: 'usdt',
    };
    const res: any = await gateRestClient.getFuturesContract(params);
    return formatSuccess(res);
  }

  // 合约交易行情
  async tickers(e: any) {
    const params: any = {
      ...e,
      settle: 'usdt',
    };
    const res: any = await gateRestClient.getFuturesTickers(params);
    return formatSuccess(res);
  }

  // k线图
  async kline(e: any) {
    const params: any = {
      ...e,
      settle: 'usdt',
    };
    const res: any = await gateRestClient.getFuturesCandles(params);
    return formatSuccess(res);
  }

  // 市场深度信息
  async orderBook(e: any) {
    const params: any = {
      ...e,
      settle: 'usdt',
    };
    const res: any = await gateRestClient?.getFuturesOrderBook(params);
    return formatSuccess(res);
  }

  // 个人交易费率
  async feiLv(e: any) {
    const params: any = { ...e, settle: 'usdt' };
    const res: any = await gateRestClient?.getTradingFees(params);
    return formatSuccess(res);
  }
}
